package com.serita.demo;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;

import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnClick;

public class MainActivity extends AppCompatActivity {

    @InjectView(R.id.btn_1)
    Button mBtn1;
    @InjectView(R.id.btn_2)
    Button mBtn2;
    @InjectView(R.id.btn_3)
    Button mBtn3;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.inject(this);
    }

    @OnClick({R.id.btn_1, R.id.btn_2, R.id.btn_3})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.btn_1:
                invoke(this,QQActivity.class,null,false);
                break;
            case R.id.btn_2:
                invoke(this,QQActivity.class,null,false);
                break;
            case R.id.btn_3:
                invoke(this,QQActivity.class,null,false);
                break;
        }
    }
    /**
     * 跳转activity页面
     *
     * @param fromActivity
     * @param toClass
     * @param bundle
     * @param isFinish
     */
    public static void invoke(final Activity fromActivity, Class<?> toClass, Bundle bundle, boolean isFinish) {
        Intent intent = new Intent(fromActivity, toClass);
        if (bundle != null) intent.putExtra("bundle", bundle);
        if (isFinish) {
            fromActivity.finish();
        }
        fromActivity.startActivity(intent);
    }
}
